package com.huarui.partproperty.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.ewaf.framework.model.ListModel;
import org.ewaf.framework.service.BaseService;

import com.huarui.part.dao.IPartPropertyDao;
import com.huarui.part.service.PartService;
import com.huarui.user.model.SessionMessage;
import com.huarui.user.security.UserHolder;

public class PartPropertyService extends BaseService {
	private final static Logger logger = Logger.getLogger(PartPropertyService.class);
	private IPartPropertyDao getDao(){
		return (IPartPropertyDao) this.dao;
	}
	
	public Map<String,Object> getCodeByCompanyIdWithPage(ListModel lm,String code){
		SessionMessage sm=UserHolder.getCurrentSessionMessage();
		Map<String,Object> map=new HashMap<String, Object>();
		map.put("companyId", sm.getCompanyId());
		map.put("code_prefix", code);
		Map<String,Object> resultMap = new HashMap<String, Object>();
		try {
			Integer count=getDao().getCountByCondition(map);
			map.put("listModel", lm);
			List<Map> resList = getDao().getCodeByCompanyIdWithPage(map);
			resultMap.put("root", resList);
			resultMap.put("totalProperty",count);
		} catch (Exception e) {
			logger.error("零件表查询出错", e);
		}
		return resultMap;
	}
}
